<template>
  <div>
    <el-row>
      <el-col :span="24">
        <h3>路由名称：</h3>
      </el-col>
      <el-col :span="24">
        <el-input v-model="addPermission.permissionName" placeholder="请输入内容" style="width: 300px"></el-input>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <h3>路由描述：</h3>
      </el-col>
      <el-col :span="24">
        <el-input style="width: 300px" v-model="addPermission.description" type="textarea" :rows="2" placeholder="请输入内容"></el-input>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <h3>路由地址：</h3>
      </el-col>
      <el-col :span="24">
        <el-input v-model="addPermission.webUrl" placeholder="请输入内容" style="width:300px;"></el-input>
      </el-col>
    </el-row>
    <el-row>
        <el-col :span="24">
          <h3>上级路由Id:</h3>
        </el-col>
        <el-col :span="24">
          <el-input v-model="addPermission.pid" placeholder="请输入内容" style="width: 300px"></el-input>
        </el-col>
      </el-row>
    <el-row>
      <el-col :span="24">
        <h3>后端权限：</h3>
      </el-col>
      <el-col :span="24">
        <el-input v-model="addPermission.permissionPath" placeholder="请输入内容" style="width:300px;"></el-input>
      </el-col>
    </el-row>
    <el-button style="margin-top: 50px;" type="warning" @click="remove">重置</el-button>
    <el-button style="margin-top: 50px;" type="success" @click="newRole">创建</el-button>
  </div>
</template>

<script>
import request from '@/utils/request'
import { Message } from 'element-ui'
export default {
  data () {
    return {
      addPermission: {
        permissionName: '',
        description: '',
        webUrl: '',
        permissionPath: '',
        permissionType: 1,
        pid: ''
      }
    }
  },
  methods: {
    remove () {
      this.addPermission = {
        permissionName: '',
        description: '',
        webUrl: '',
        permissionPath: '',
        permissionType: 1,
        pid: ''
      }
      console.log(1)
    },
    newRole () {
      request({
        url: '/admin/permission/addPermission',
        method: 'post',
        data: this.addPermission
      }).then(res => {
        if (res.code === '00000000') {
          Message({
            message: res.message,
            type: 'success',
            duration: 3 * 1000
          })
          this.remove()
        } else {
          Message({
            message: res.message,
            type: 'error',
            duration: 3 * 1000
          })
        }
      })
    }
  }
}
</script>

<style>
</style>
